using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using BLL;
using BLL.Impl;
using System.Collections.Generic;

namespace WebUI.Custom
{
    public partial class Custom_List : BasicPage
    {

        private IAdminManager adminManager;
        private List<Model.Custom> customes;
        protected void Page_Load(object sender, EventArgs e)
        {
            adminManager = BLLFactory.CreateAdminManager();
            customes = adminManager.ListCustom();
            if (!IsPostBack)
            {
                Display();
            }
        }

        private void Display()
        {
            this.grvCustomList.DataSource = customes;
            this.grvCustomList.DataKeyNames = new string[] { "PersonSN" };
            this.grvCustomList.DataBind();
        }

        protected void btnSeach_Click(object sender, EventArgs e)
        {
            Model.Custom custom = new Model.Custom();
            if (!String.IsNullOrEmpty(this.txtPersonSn.Text.Trim()))
            {
                custom.PersonSN = Int32.Parse(this.txtPersonSn.Text.Trim());
            }
            if (!String.IsNullOrEmpty(this.txtPersonName.Text))
            {
                custom.PersonName = this.txtPersonName.Text;
            }
            if (!String.IsNullOrEmpty(this.txtTel.Text))
            {
                custom.Tel = this.txtTel.Text;
            }
            if (!String.IsNullOrEmpty(this.txtEmail.Text))
            {
                custom.Email = this.txtEmail.Text;
            }
            customes=adminManager.SelectCustom(custom);
            Display();
        }
    }
}
